package com.bluesky.plum.uimodels.render.swing.components.containers.window;

import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JMenuBar;

import com.bluesky.plum.uimodels.standard.UIComponent;
import com.bluesky.plum.uimodels.standard.components.containers.Panel;
import com.bluesky.plum.uimodels.standard.components.containers.window.MainWindow;
import com.bluesky.plum.uimodels.standard.components.menu.MenuBar;

public class SMainWindow extends MainWindow {
	protected JFrame frame;

	public SMainWindow() {
		super();
		
		frame = new JFrame();

		frame.setSize(800, 600);

		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}

	@Override
	protected void init() {
		// TODO Auto-generated method stub
		super.init();
		
		frame.getContentPane().add(
				(JComponent) contentPanel.getNativeComponent());
	}
	@Override
	public void setMenuBar(MenuBar menuBar) {

		super.setMenuBar(menuBar);

		frame.setJMenuBar((JMenuBar) menuBar.getNativeComponent());
	}

	@Override
	public void setContentPanel(Panel contentPanel) {

		super.setContentPanel(contentPanel);

		frame.getContentPane().removeAll();
		frame.getContentPane().add(
				(JComponent) contentPanel.getNativeComponent());
	}

	@Override
	public void addChildComponent(UIComponent uic) {

		super.addChildComponent(uic);

		frame.add((JComponent) uic.getNativeComponent());
	}

	@Override
	public Object getNativeComponent() {

		return frame;
	}

	@Override
	public void pack() {

		// wholeBox.validate();
		frame.pack();
	}

	@Override
	public void setVisible(boolean visible) {

		super.setVisible(visible);
		frame.setVisible(visible);
	}
	@Override
	public void setTitle(String title) {
		
		super.setTitle(title);
		
		frame.setTitle(title);
	}
}
